package com.firexxx.study.lock.task;

import com.firexxx.study.performancetest.task.IFixedTimeConsumeTask;
import com.firexxx.study.performancetest.timeconsume.ITimeConsume;
import lombok.Data;

import java.util.concurrent.atomic.AtomicLong;

/**
 * TODO
 *
 * @author fireXXX
 * @date 2020/11/19 0:14
 **/
public class AtomicConsumeTask extends IFixedTimeConsumeTask {

    private AtomicLong atomicLong = new AtomicLong(0);

    @Override
    public Object runOne() {
        getTimeConsume().run();
        atomicLong.getAndIncrement();

        return null;
    }

    @Override
    public void setCount(long count) {
        atomicLong = new AtomicLong(count);
    }

    @Override
    public long getCount() {
        return atomicLong.get();
    }
}